Add an assertion to HashSet::get_or_insert_with#518
Add an assertion to HashSet::get_or_insert_with#518cuviper wants to merge 1 commit intorust-lang:masterfrom
HashSet::get_or_insert_with#518Conversation
Since the Rust libs-api team considers it problematic for `HashSet<T>` to be unreliable with well-behaved `T` (not user-controlled), we should not allow mismatches to be inserted through `get_or_insert_with`.
|
I didn't notice #400 before, but I think that's doing a lot more than is really needed for the immediate problem. For instance, I don't think it's important to compare the hashes, because that calculation is not under user control here. And value equality already implies hash equality, especially for known-good non-user types. |
I can correct the code if necessary. |
I removed unnecessary code. Now the comparison is carried out by values. I don’t think this will affect performance. I use the |
|
For some background, this came up while I was trying to remove |
Well, But You need to either rewrite |
That would be unsound, because a user could follow that with a We could add a similar |
That's right, I forgot about the |
|
Subsumed by #555. |
Since the Rust libs-api team considers it problematic for
HashSet<T>to be unreliable with well-behaved
T(not user-controlled), we shouldnot allow mismatches to be inserted through
get_or_insert_with.